import 'package:flutter/material.dart';

/// 2022年更新  适配 flutter 3.0
class ClipHome extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return ClipHomeState();
  }
}

class ClipHomeState extends State {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Chip")),
      body: Center(
        child: buildChip(),
      ),
    );
  }

  buildChip() {
    return Chip(
      label: const Text("测试"),
      labelStyle: const TextStyle(fontSize: 14, color: Colors.red),
      labelPadding: const EdgeInsets.only(left: 10, right: 10),

      ///左侧显示小图标
      avatar: const CircleAvatar(
        backgroundColor: Colors.blue,
        foregroundColor: Colors.white,
        child: Text("A"),
      ),

      ///右侧的按钮
      deleteIcon: const Icon(Icons.close),
      //删除按钮的颜色
      deleteIconColor: Colors.orange,
      //删除的点击事件
      onDeleted: () {
        print("点击了deleted");
      },
      //删除 长按小提示
      deleteButtonTooltipMessage: "删除",

      ///
      elevation: 10,
      //阴影颜色
      shadowColor: Colors.blue,
      //背景颜色
      backgroundColor: Color(0xfffafafa),
    );
  }

  Widget buildChip1() {
    return const Chip(
      label: Text("测试"),
      ///左侧显示小图标
      avatar: CircleAvatar(
        child: Text("A"),
      ),
      ///右侧的按钮
      deleteIcon: Icon(Icons.close),
    );
  }
}
